#include "gofgame/dungeonkeeper/game/item/HpPotion.h"

using namespace gofgame::dungeonkeeper::game::item;

HpPotion::HpPotion(){
	this->id = 1;
	this->price = 10;
	tip = new string("use it for recovery hp 20");
}

HpPotion::~HpPotion(){
	delete tip;
}

bool HpPotion::init(){
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!CCNode::init());
		this->texture = CCSprite::create("item/hp.png");
		this->addChild(texture);
		bRet = true;
	} while (0);
	return bRet;
}

void HpPotion::useForHero(Hero *hero){
	int currentHp = hero->getCurrentHp();
	int maxHp = hero->getOrigHP();
	if(currentHp>0) {
		if(currentHp + 20 >= maxHp){
			currentHp = maxHp;
		}
		hero->setCurrentHp(currentHp);
	}
}